package com.grts.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.grts.dao.ClassroombeanMapper;
import com.grts.pojo.Classroombean;
import com.grts.service.IClassroomService;
import com.grts.utils.PageModel;
@Service
public class ClassroomServiceImpl implements IClassroomService {
@Resource
private ClassroombeanMapper dao;
private PageModel page = new PageModel();
	@Override
	public int deleteByPrimaryKey(Integer cid) {
		return dao.deleteByPrimaryKey(cid);
	}

	@Override
	public int insert(Classroombean record) {
		return dao.insert(record);
	}

	@Override
	public int insertSelective(Classroombean record) {
		return dao.insertSelective(record);
	}

	@Override
	public Classroombean selectByPrimaryKey(Integer cid) {
		return dao.selectByPrimaryKey(cid);
	}

	@Override
	public int updateByPrimaryKeySelective(Classroombean record) {
		return dao.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(Classroombean record) {
		return dao.updateByPrimaryKey(record);
	}


	public PageModel queryByPage(Map paramMap) {
		int currentPage=(int) paramMap.get("currentPage");
		
		int pageSize=(int)paramMap.get("pageSize");
		System.out.println(paramMap.get("cnumber"));
		//查询总条数
		int totalCount=dao.queryTotalCount(paramMap);
		int pageCount=(totalCount-1)/pageSize+1;
		System.out.println("currentPage:"+currentPage+",pageSize:"+pageSize+",totalCount:"+totalCount+",pageCount:"+pageCount);
		//查询结果为List
		page.setResult(dao.queryByPage(paramMap));
		page.setCurrentPage(currentPage);
		page.setPageSize(pageSize);
		page.setTotalCount(totalCount);
		page.setPageCount(pageCount);
		return page;
	}
}
